import numpy as np
import cv2 as cv

# 加载彩色灰度图像
img = cv.imread('D:/test/q.png', cv.IMREAD_UNCHANGED)
cv.imshow('image', img)
k = cv.waitKey(0) & 0xff
if k == 27:
    cv.destroyAllWindows()
elif k == ord('s'):
    cv.imwrite('out.png', img)
    cv.destroyAllWindows()
